Description:
This box is designed to give a rundown of basic statistics for a scoop site. It returns the total number of stories, comments, comment ratings, and users for a site. By default it requires the perm "story_admin", but it is trivial to change.
Box Code:
return 'No Access' unless $S->have_perm('story_admin');
my $return='|smallfont|<table border=0>';
my ($rv,$sth) = $S->db_select({
WHAT => 'count(*) as c',
FROM => 'stories'});
if ( $rv ) {
while (my $r = $sth->fetchrow_hashref) {
$return .= qq{<tr><td>Stories:</td><td> $r->{c}</td></tr>};
};
}
#comments
my ($rv,$sth) = $S->db_select({
WHAT => 'count(*) as c',
FROM => 'comments'});
if ( $rv ) {
while (my $r = $sth->fetchrow_hashref) {
$return .= qq{<tr><td>Comments:</td><td> $r->{c}</td></tr>};
};
}
#comment ratings
my ($rv,$sth) = $S->db_select({
WHAT => 'count(*) as c',
FROM => 'commentratings'});
if ( $rv ) {
while (my $r = $sth->fetchrow_hashref) {
$return .= qq{<tr><td>Ratings:</td><td> $r->{c}</td></tr>};
};
}
#users
my ($rv,$sth) = $S->db_select({
WHAT => 'count(*) as c',
FROM => 'users'});
if ( $rv ) {
while (my $r = $sth->fetchrow_hashref) {
$return .= qq{<tr><td>Users:</td><td> $r->{c}</td></tr>};
};
}
$sth->finish();
$return .= '</table>|smallfont_end|';
return $return;
|